package net.lzzy.practices.entities;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 *@author lzzy_gxy on 2022/5/8.
 *Description:
 */
@Entity
@Setter
@Getter
public class Question extends BaseEntity{
    @Transient
    public static final int TYPE_SINGLE=0;
    @Transient
    public static final int TYPE_JUDGE=1;
    @Transient
    public static final int TYPE_MULTI=2;
    private int type;
    private String content;
    private String analysis;
    private int ordinal;
    @OneToMany(cascade = CascadeType.PERSIST,mappedBy = "question")
    private List<Option> options;
    @ManyToOne
    private Chapter chapter;
    public Question(){}
    @OneToMany(mappedBy = "student")
    private List<Result> results=new ArrayList<>();

    @JsonManagedReference
    public List<Option> getOptions() {
        return options;
    }

    @JsonBackReference
    public Chapter getChapter() {
        return chapter;
    }

    @JsonManagedReference
    public List<Result> getResults() {
        return results;
    }
}
